home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Singles Flirt Up Your Life! (German)
/
Singles Flirt Up Your Life.iso
/
data1.cab
/
Statemachine
/
mimic.lua
< prev
next >
Wrap
Text File
|
2004-01-29
|
6KB
|
276 lines
-- mimic state machine
beginStateMachine()
onEnter(function(msg)
-- print("mimic enter");
setState("neutral1");
end )
-- onReturn(function(msg)
-- nextAction();
-- end )
-- onMsg("queue", function(msg)
-- nextAction();
-- end )
-- general mimic control
onMsg("stop", function(msg)
print("stop mimic" .. getParent().getCharacterName());
setState("stop");
end )
onMsg("neutral", function(msg)
local stateName = "neutral" .. random(1,3);
print(getParent().getCharacterName() .. " neutral with " .. stateName);
setState(stateName);
end )
onMsg("smile", function(msg)
local stateName = "smile" .. random(1,5);
print(getParent().getCharacterName() .. "smile with " .. stateName);
setState(stateName);
end )
onMsg("talk", function(msg)
local stateName = "talk" .. random(1,2);
setState(stateName);
end )
onMsg("angry", function(msg)
local stateName = "angry" .. random(1,2);
print(getParent().getCharacterName() .. "angry with " .. stateName);
setState(stateName);
end )
onMsg("sad", function(msg)
local stateName = "sad" .. random(1,2);
print(getParent().getCharacterName() .. "sad with " .. stateName);
setState(stateName);
end )
onMsg("eyeClose", function(msg)
-- print("eyeClose");
setState("eyeClose");
end )
-- eye blink
onMsg("eyeBlink", function(msg)
-- print("eyeBlink");
if (getState() ~= "stop") and (getState() ~= "eyeClose") then
addAnimation("mimicEyeBlink");
end;
sendDelayedMsgThis("eyeBlink", random(2000, 7000));
end )
--onMsg("dlgPose", function(msg)
-- print("mimic dlgPose:" .. msg.data);
-- storeData("poseType", msg.data);
-- setState("dlgPose");
--end )
onDefault( function(msg)
if (strfind(msg.name, "mimic") == 1) then
storeData("animName", msg.name);
if (getState() == "pose") then
sendMsgThis("poseChanged");
else
setState("pose");
end
--setState("stop");
--setDelayedState("pose", 300);
end
end )
----------------------------------------------------------------------------------
-- STATES ------------------------------------------------------------------------
----------------------------------------------------------------------------------
-- neutral
state("stop")
onEnter(function(msg)
-- print("stop");
stopPose();
end )
state("neutral1")
onEnter(function(msg)
-- print("neutral1");
setPose("mimicNeutral1");
sendDelayedMsgThis("eyeBlink", random(2000, 7000));
setDelayedState("neutral2", random(3000, 8000));
end )
state("neutral2")
onEnter(function(msg)
-- print("neutral2");
setPose("mimicNeutral2");
sendDelayedMsgThis("eyeBlink", random(2000, 7000));
setDelayedState("neutral3", random(3000, 8000));
end )
state("neutral3")
onEnter(function(msg)
-- print("neutral3");
setPose("mimicNeutral3");
sendDelayedMsgThis("eyeBlink", random(2000, 7000));
setDelayedState("neutral1", random(3000, 8000));
end )
-- eyeClose
state("eyeClose")
onEnter(function(msg)
print("eyeClose");
setPose("mimicEyeClose");
end )
-- smile1
state("smile1")
onEnter(function(msg)
print("smile1");
setPose("mimicSmile1");
sendDelayedMsgThis("eyeBlink", random(2000, 7000));
sendDelayedMsgThis("neutral", random(3000, 8000));
end )
-- smile2
state("smile2")
onEnter(function(msg)
print("smile2");
setPose("mimicSmile2");
sendDelayedMsgThis("eyeBlink", random(2000, 7000));
sendDelayedMsgThis("neutral", random(3000, 8000));
end )
-- smile3
state("smile3")
onEnter(function(msg)
print("smile3");
setPose("mimicSmile3");
sendDelayedMsgThis("eyeBlink", random(2000, 7000));
sendDelayedMsgThis("neutral", random(3000, 8000));
end )
-- smile4
state("smile4")
onEnter(function(msg)
-- print("smile4");
setPose("mimicSmile4");
sendDelayedMsgThis("eyeBlink", random(2000, 7000));
sendDelayedMsgThis("neutral", random(3000, 8000));
end )
-- smile5
state("smile5")
onEnter(function(msg)
-- print("smile5");
setPose("mimicSmile5");
sendDelayedMsgThis("eyeBlink", random(2000, 7000));
sendDelayedMsgThis("neutral", random(3000, 8000));
end )
-- angry1
state("angry1")
onEnter(function(msg)
print("angry1");
setPose("mimicAngry1");
sendDelayedMsgThis("eyeBlink", random(2000, 7000));
sendDelayedMsgThis("neutral", random(3000, 8000));
end )
-- angry1
state("angry2")
onEnter(function(msg)
print("angry2");
setPose("mimicAngry2");
sendDelayedMsgThis("eyeBlink", random(2000, 7000));
sendDelayedMsgThis("neutral", random(3000, 8000));
end )
-- sad1
state("sad1")
onEnter(function(msg)
print("sad2");
setPose("mimicSad1");
sendDelayedMsgThis("eyeBlink", random(2000, 7000));
sendDelayedMsgThis("neutral", random(3000, 8000));
end )
-- sad1
state("sad2")
onEnter(function(msg)
print("sad2");
setPose("mimicSad2");
sendDelayedMsgThis("eyeBlink", random(2000, 7000));
sendDelayedMsgThis("neutral", random(3000, 8000));
end )
-- talk1
state("talk1")
onEnter(function(msg)
print("talk1");
local character = getParent();
if (character.isMale() == true) then
setPose("mimicTalkMike1");
else
setPose("mimicTalkElaine1");
end
character.playSound(genderizeReal(character, "mimicTalk") .. "1", SPEECH);
end )
onMsg("end", function(msg)
sendMsgThis("neutral");
end )
state("talk2")
onEnter(function(msg)
print("talk2");
local character = getParent();
if (character.isMale() == true) then
setPose("mimicTalkMike2");
else
setPose("mimicTalkElaine2");
end
character.playSound(genderizePink(character, "mimicTalk") .. "2", SPEECH);
end )
onMsg("end", function(msg)
sendMsgThis("neutral");
end )
state("pose")
onEnter(function(msg)
local animName = retrieveData("animName");
print("pose onEnter (" .. animName .. ")");
setPose(animName);
end )
onMsg("poseChanged", function(msg)
local animName = retrieveData("animName");
print(" pose onMsg poseChanged (" .. animName .. ")");
setPose(animName);
end )
endStateMachine()